home *** CD-ROM | disk | FTP | other *** search
- Path: zetnet.co.uk!demon!stsdaveb.demon.co.uk
- From: dave@stsdaveb.demon.co.uk (Dave Thornton)
- Newsgroups: comp.lang.c
- Subject: Re: Help!
- Date: Fri, 26 Jan 1996 15:55:12 GMT
- Organization: Severn Trent Systems
- Message-ID: <3108f3cd.14615158@news.demon.co.uk>
- References: <4ea5p4$j0s@ratree.psu.ac.th>
- NNTP-Posting-Host: stsdaveb.demon.co.uk
- X-NNTP-Posting-Host: stsdaveb.demon.co.uk
- X-Newsreader: Forte Agent .99c/16.141
-
- On 26 Jan 1996 09:09:56 GMT, s3610165@maliwan.psu.ac.th (Sanon
- CHAOCHAIYAPORN) wrote:
-
- >Dear all
- >
- > There is a file, hi.bat, in my 'h:\data' directory and I try to
- >run it by C program but it fail. Please, advice to me?
- >
- >Source:
- >
- >#include<stdio.h>
- >#include<stdlib.h>
- >#include<conio.h>
- >#include<dir.h>
- >
- >main()
- >{
- >clrscr();
- >chdir("h:\data");
- >system("hi.bat");
- >getch()
- >}
-
- >
- >
- >--
- > ----------------------------------------------------------------
- > | | |
- > | Sanon Chaochaiyaporn | Prince of Songkla University |
- > | s3610165@maliwan.psu.ac.th | Hadyai, Thailand |
- > | | |
- > ----------------------------------------------------------------
-
- Have you checked the return code of the chdir() function. It may not
- be changing into the directory. ie
-
- main( int argc, char * argv[])
- {
- char * string = "Error Message";
-
- clrscr();
-
- if ( chdir("h:\data") == -1)
- {
- printf("Error changing to .\n");
- perror(string);
- }
- else
- {
- system("hi.bat");
- getch();
- }
- }
-
- Unfortunat;y there is no way to determine the exit status of the
- program run using system(). Use one of the spawn functions if an exit
- status is required.
-
- Hope this is of use.
- -------------------------------------------------------------------------------
- | Dave Thornton | email dave@stsdaveb.demon.co.uk |
- | Staffs, England | |
- -------------------------------------------------------------------------------
-